package ae.pcfc.etks.online.itworx.ehs.web.delegate;

import java.util.Date;
import java.util.List;

import ae.pcfc.etks.online.itworx.ehs.web.entity.OFCRequest;
import ae.pcfc.etks.online.itworx.ehs.web.entity.OFCRequestHistory;
import ae.pcfc.etks.online.itworx.ehs.web.entity.Request;
import ae.pcfc.etks.online.itworx.ehs.web.enums.RequestAction;
import ae.pcfc.etks.online.itworx.ehs.web.enums.RequestStatus;
import ae.pcfc.etks.online.itworx.ehs.web.enums.UserType;
import ae.pcfc.etks.online.itworx.ehs.web.exception.CommunicationException;
import ae.pcfc.etks.online.itworx.ehs.web.exception.FNPServiceExpcetion;
import ae.pcfc.etks.online.itworx.ehs.web.exception.IMSException;
import ae.pcfc.etks.online.itworx.ehs.web.exception.InvalidInputException;
import ae.pcfc.etks.online.itworx.ehs.web.exception.WorkFlowException;
import ae.pcfc.etks.online.itworx.ehs.web.model.RequestSearchCriteria;


public interface WorkflowDelegate extends BaseDelegate {

	long getAllRequestsSize(String userId, String companyName, UserType user,
			Date creationDateFrom, Date creationDateTo,
			RequestStatus requestStatus);

	/*List<Request> getAllRequests(String userId, String companyName,
			UserType user, Date creationDateFrom, Date creationDateTo,
			RequestStatus requestStatus, RequestField sortField,
			boolean ascending, int pageNo);*/
	
	List<OFCRequest> getAllRequestsByStatus(List<RequestStatus>  requestsStatus);

	OFCRequest getRequestDetails(Long requestId);

	List<OFCRequestHistory> getRequestHistory(Long requestId);

	void createOFCRequest(OFCRequest ofcRequest) throws InvalidInputException, CommunicationException, RuntimeException;
	
	void updateOFCRequest(OFCRequest ofcRequest);
	
	boolean sendK2Mail(String processId ,String userName, String actionType, OFCRequest ofcRequest, boolean isOfficer) throws InvalidInputException, CommunicationException, RuntimeException;
	
	List<Request> getActiveTasks(String processName,
			String userName, boolean isOffecier,Long requestId,RequestStatus status,String submissionDate) throws InvalidInputException, CommunicationException, RuntimeException;
	
	/*this method is used for both customer and officer "My Requests" page...It return list of requests from EHS DB..
	 * no hitting to K2 service and the returned requests do not contain "Serial number" */
	List<Request> getAllRequests(String userName,boolean isOffecier,RequestSearchCriteria criteria)throws InvalidInputException, CommunicationException, RuntimeException;
	
	boolean isValidOfficer(String officerId)throws InvalidInputException, CommunicationException, RuntimeException;
	
	//userId can be customerId or officerId
	OFCRequest getDetails(Long requestId,String userId, boolean isOfficer)throws InvalidInputException, CommunicationException, RuntimeException;
	
	List<Request> getActiveTasks(RequestSearchCriteria searrchCriteria, String processName,
			String userName, boolean isOffecier, boolean isAssigned) throws InvalidInputException, CommunicationException, RuntimeException;
	
	long getAllRequestsSize(String userName, boolean isOfficer,
			RequestSearchCriteria searchCriteria)throws InvalidInputException, CommunicationException, RuntimeException;
	
	long getAllActiveTasksSize(String processName,String userName, boolean isOfficer,
			RequestSearchCriteria searchCriteria, boolean isAssigned)throws InvalidInputException, CommunicationException, RuntimeException;
	
	void cancelRequest(long requestId, String username, boolean isOfficer) throws InvalidInputException, CommunicationException,FNPServiceExpcetion,IMSException;
	
	void closeRequest(long requestId, String username, boolean isOfficer) throws InvalidInputException, CommunicationException,FNPServiceExpcetion,IMSException;
	
	boolean manipulateRequest(OFCRequest ofcRequest,String userName,boolean isOfficer,RequestAction action) throws CommunicationException, InvalidInputException;
	
	public int createOFCProcess(OFCRequest ofcRequest) throws InvalidInputException, CommunicationException, RuntimeException;

	boolean manipulateIMSRequest(OFCRequest request, String userName, boolean isOfficer,RequestAction action, String imsStatus, Date processingDate) throws WorkFlowException;

	long getActiveRequestSize(String userName);
}
